package nl.unimaas.micc.umsnooker.simulation.event;

import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.jme.math.FastMath;
import com.jme.math.Vector3f;

import nl.unimaas.micc.umsnooker.domain.BilliardBall;
import nl.unimaas.micc.umsnooker.domain.Ball.BallState;
import nl.unimaas.micc.umsnooker.math.XYRotationTrans3D;

public class SetValuesEvent extends Event
{
	static final Logger logger = Logger.getLogger(SetValuesEvent.class
			.getName());

	private Vector3f v, av;
	private BallState state;

	public SetValuesEvent(float time, Set<BilliardBall> balls, Vector3f v,
			Vector3f av, BallState state)
	{
		super(time, balls);
		this.v = v;
		this.av = av;
		this.state = state;
	}

	@Override
	public void handle(Map<BilliardBall, BilliardBall> target)
	{
		for (BilliardBall b : this.getBalls(target))
		{
			logger.log(Level.FINER, "Old ball state", b);
			b.setAngularVelocity(av);
			b.setVelocity(v);
			b.setState(state);
			b.setTime(getTime());
			logger.log(Level.FINER, "New ball state", b);
		}
	}

}
